package Control;

import Entity.MsgPackage;
import GUI.DetermineStageManagerGui;
import GUI.ScreenManager;

/**
* Controls the instance of Determine stage manager 
* This class sends and gets data from the server 
* and display it on the panel.
* @author Nofar
 */ 
public class DetermineStageManager {

	private DetermineStageManagerGui dsmGui;
	private MsgPackage det_stage_manager_msg;
	private int[] manager ;
	
	/**
	 * the constructor
	 */
	public DetermineStageManager() {
		dsmGui = new DetermineStageManagerGui();
		det_stage_manager_msg= new  MsgPackage();
		manager = new int[4];
	}
	
	/**
	 * 
	 * @return  DetermineStageManagerGui
	 */
	public DetermineStageManagerGui getDSMgui(){
			return dsmGui;
	}
	
	/**
	 * This method sends the supervisor decision about the
	 * manager of each stage to the server
	 *  The server sends an answer (received from query from database) 
	 *  and the control display it in a message
	 * @return boolean
	 */
	public void submitBnt_prassed(){
		manager[0] =Integer.parseInt((String)dsmGui.getStage1().getSelectedItem());
		manager[1] =Integer.parseInt((String) dsmGui.getStage2().getSelectedItem());
		manager[2] =Integer.parseInt((String) dsmGui.getStage3().getSelectedItem());
		manager[3] =Integer.parseInt((String)dsmGui.getStage4().getSelectedItem());
		det_stage_manager_msg.setObject(manager);
		det_stage_manager_msg.setOp_code(OP_CODE.DETERMINE_MANAGER);
		ScreenManager.getConnection().accept(det_stage_manager_msg);	
	}

}
